package designpatterns.strategy;

// 上下文
public class Context {
    private Strategy strategy;
    
    public Context(int type) {
        this.strategy = switch (type) {
            case 1 -> new Strategy1();
            case 2 -> new Strategy2();
            case 3 -> new Strategy3();
            default -> throw new IllegalStateException("Unexpected value: " + type);
        };
    }

    public int getResult() {
        return strategy.operate1();
    }
}
